package org.example.salesystem.mapper;

import org.apache.ibatis.annotations.*;
import org.example.salesystem.entity.Complaint;
import java.util.List;

@Mapper
public interface ComplaintMapper {
    @Select("SELECT * FROM complaint WHERE id = #{id}")
    Complaint getById(Long id);

    @Select("SELECT * FROM complaint WHERE reporter_phone = #{reporterPhone}")
    List<Complaint> getByReporterPhone(String reporterPhone);

    @Select("SELECT * FROM complaint")
    List<Complaint> getAll();

    @Insert("INSERT INTO complaint(product_id, reporter_phone, content, report_time, status) " +
            "VALUES(#{productId}, #{reporterPhone}, #{content}, #{reportTime}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Complaint complaint);

    @Update("UPDATE complaint SET status = #{status}, feedback = #{feedback}, feedback_time = #{feedbackTime} " +
            "WHERE id = #{id}")
    int updateStatus(Complaint complaint);
} 